//
// Created by user on 2022/1/13.
//
#include <iostream>
#include <vector>
#include <string>
using namespace std;

string sortString(string s) {
    vector<int> count(26);
    for(char c:s){
        count[c-'a']++;
    }
    string res;
    while (res.length()<s.length()){
        for (int i = 0; i <26 ; ++i) {
            if(count[i]){
                res.push_back(i+'a');
                count[i]--;
            }

        }

        for (int i =25; i >=0 ; i--) {
            if(count[i]){
                res.push_back(i+'a');
                count[i]--;
            }

        }
    }
    return res;
}

int main(){


    return 0;
}